<?php $id = (isset($id)) ? ' id="'.$id.'"' : '';?>

<select name="<?=$name?>"<?=$id?>>
    <?php foreach($array as $key => $val):?>
    <option value="<?php print $key?>"><?php print $val?>
    <?php endforeach;?>
</select>